package utils;

import java.sql.SQLException;

public class DbInit {

    private static String initDDL =
            "CREATE TABLE `users_t` (" +
            "  `id` bigint NOT NULL AUTO_INCREMENT," +
            "  `name` varchar(64) NOT NULL," +
            "  `nick` varchar(64) NULL," +
            "  `passwordHash` varchar(64) NOT NULL," +
            "  `headPic` varchar(255) NULL," +
            "  `win` int NOT NULL DEFAULT 0," +
            "  `lost` int NOT NULL DEFAULT 0," +
            "  `run` int NOT NULL DEFAULT 0," +
            "  `score` bigint NOT NULL DEFAULT 10,\n" +
            "  `joinRank` int NOT NULL DEFAULT 0,\n" +
            "  `state` varchar(16) NOT NULL DEFAULT \'启用\'," +
            "  PRIMARY KEY (`id`)," +
            "  UNIQUE INDEX `idx_users_t_id`(`id`) USING BTREE," +
            "  UNIQUE INDEX `idx_users_t_name`(`name`) USING HASH," +
            "  FULLTEXT INDEX `idx_users_t_nick`(`nick`) USING HASH" +
            ")";

    public static void init() {
        try {
            JDBCConnection conn = JDBCFactory.takeJDBC();
                conn.update(initDDL);
            JDBCFactory.returnBack(conn);
            System.out.println("returnedBack");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    private DbInit() {}

    public static void main(String[] args) {
        init();
    }
}
